package interfaces.inputValidation;

import fileHandling.language.LanguageLoader;
import fileHandling.language.interfaces.Validation;

public class TextInputChecker implements InputChecker {
	
	private String[] values;
	
	public TextInputChecker(String... values) {
		this.values = values;
	}
	
	@Override
	public boolean isValid(String input) {
		for(String v : values) {
			if(input.equals(v)) return true;
		}
		return false;
	}
	
	@Override
	public String getDescription() {
		String onlyPossible = LanguageLoader.get(Validation.OnlyTheFollowingArgumentsArePossible);
		StringBuilder builder = new StringBuilder(onlyPossible);
		
		builder.append(": ");
		
		int lastIndex = values.length - 1;
		for(int i = 0; i < values.length; i++) {
			builder.append(values[i]);
			if(i != lastIndex) builder.append(", ");
		}
		
		return builder.toString();
	}
}